﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;

namespace Marmat.Common.Http
{

    /// <summary>
    /// Http文件的存储集合。
    /// </summary>
    public class FormFileCollection:IEnumerable<FormFileInfo>
    {
        private readonly List<FormFileInfo> collection = new List<FormFileInfo>();

        /// <summary>
        /// 添加文件。
        /// </summary>
        /// <param name="fileName">等待上传的文件，含路径</param>
        public void Add(string fileName)
        {
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileName);
            this.Add(fileName, fileInfo.Name);
        }

        /// <summary>
        /// 添加文件。
        /// </summary>
        /// <param name="fileName">等待上传的文件，含路径</param>
        /// <param name="name">文件上传到服务器的名称</param>
        public void Add(string fileName, string name)
        {
            FormFileInfo item = new FormFileInfo();
            item.Name = name;
            item.FileName = fileName;
            collection.Add(item);
        }

        public IEnumerator<FormFileInfo> GetEnumerator()
        {
            return collection.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return this.GetEnumerator();
        }
    }
}
